home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / OLE2BOOK.ZIP / CHAP12.ZIP / PATRON / PATRON.H < prev    next >
C/C++ Source or Header  |  1993-06-27  |  7KB  |  239 lines

  1. /*
  2.  * PATRON.H
  3.  * Modifications for Chapter 12
  4.  *
  5.  * Single include file that pulls in everything needed for other source
  6.  * files in the application.
  7.  *
  8.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Software Design Engineer
  11.  * Microsoft Systems Developer Relations
  12.  *
  13.  * Internet  :  kraigb@microsoft.com
  14.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  15.  */
  16.  
  17.  
  18. #ifndef _PATRON_H_
  19. #define _PATRON_H_
  20.  
  21. #include <windows.h>
  22.  
  23. #include <ole2.h>
  24. #include <ole2ver.h>
  25. #include <ole2ui.h>
  26. #include <bookguid.h>
  27.  
  28. extern "C"
  29.     {
  30.     #include <commdlg.h>
  31.     #include <print.h>
  32.     }
  33.  
  34. #include <classlib.h>
  35. #include "resource.h"
  36. #include "pages.h"
  37.  
  38.  
  39. //PATRON.CPP:  Frame object that creates a main window
  40.  
  41. class __far CPatronFrame : public CFrame
  42.     {
  43.     private:
  44.         BOOL            m_fInitialized;     //OleInitialize worked
  45.  
  46.     protected:
  47.         //Overridable for creating a CPatronClient
  48.         virtual LPCClient CreateCClient(void);
  49.  
  50.         virtual BOOL      FMessageHook(HWND, UINT, WPARAM, LPARAM, LRESULT FAR *);
  51.         virtual BOOL      FRegisterAllClasses(void);
  52.         virtual UINT      CreateGizmos(void);
  53.         virtual LRESULT   OnCommand(HWND, WPARAM, LPARAM);
  54.  
  55.     public:
  56.         CPatronFrame(HINSTANCE, HINSTANCE, LPSTR, int);
  57.         virtual ~CPatronFrame(void);
  58.  
  59.         //Overrides
  60.         BOOL FInit(LPFRAMEINIT);
  61.  
  62.         virtual void     UpdateMenus(HMENU, UINT);
  63.         virtual void     UpdateGizmos(void);
  64.  
  65.     };
  66.  
  67.  
  68. typedef CPatronFrame FAR * LPCPatronFrame;
  69.  
  70.  
  71.  
  72.  
  73.  
  74. //CLIENT.CPP
  75.  
  76. /*
  77.  * The only reason we have a derived class here is to override
  78.  * CreateCDocument so we can create our own type as well as
  79.  * overriding NewDocument to perform one other piece of work once the
  80.  * document's been created.
  81.  */
  82.  
  83. class __far CPatronClient : public CClient
  84.     {
  85.     protected:
  86.         //Overridable for creating a new CDocument
  87.         virtual LPCDocument CreateCDocument();
  88.  
  89.     public:
  90.         CPatronClient(HINSTANCE);
  91.         virtual ~CPatronClient(void);
  92.     };
  93.  
  94. typedef CPatronClient FAR * LPCPatronClient;
  95.  
  96.  
  97.  
  98. //DOCUMENT.CPP
  99.  
  100. //Constant ID for the pages window that lives in a document window
  101. #define ID_PAGES            723
  102.  
  103.  
  104. class __far CPatronDoc : public CDocument
  105.     {
  106.     //These need access to FQueryPasteFromData, FPasteFromData
  107.     friend class CDropTarget;
  108.     friend class CDropSource;
  109.  
  110.     protected:
  111.         LONG            m_lVer;         //Loaded data version
  112.         LPCPages        m_pPG;          //Pages window in us.
  113.         LPSTORAGE       m_pIStorage;    //Root storage for document.
  114.         BOOL            m_fPrintSetup;  //Enable printer setup if no tenants.
  115.  
  116.         class CDropTarget FAR *m_pDropTarget;  //Registered target.
  117.  
  118.         UINT            m_cfEmbeddedObject;    //Clipboard formats
  119.         UINT            m_cfObjectDescriptor;
  120.         //CHAPTER12MOD
  121.         UINT            m_cfLinkSource;
  122.         UINT            m_cfLinkSrcDescriptor;
  123.         BOOL            m_fShowTypes;          //Show Objects active?
  124.         //End CHAPTER12MOD
  125.  
  126.     protected:
  127.         virtual BOOL     FMessageHook(HWND, UINT, WPARAM, LPARAM, LRESULT FAR *);
  128.  
  129.         BOOL             FQueryPasteFromData(LPDATAOBJECT, LPFORMATETC, LPTENANTTYPE);
  130.         //CHAPTER12MOD
  131.         BOOL             FQueryPasteLinkFromData(LPDATAOBJECT, LPFORMATETC, LPTENANTTYPE);
  132.         //End CHAPTER12MOD
  133.  
  134.         BOOL             FPasteFromData(LPDATAOBJECT, LPFORMATETC, TENANTTYPE
  135.                              , LPPATRONOBJECT, DWORD, BOOL);
  136.  
  137.     public:
  138.         CPatronDoc(HINSTANCE);
  139.         virtual ~CPatronDoc(void);
  140.  
  141.         virtual BOOL     FInit(LPDOCUMENTINIT);
  142.         virtual void     Clear(void);
  143.  
  144.         virtual BOOL     FDirtyGet(void);
  145.         virtual void     Delete(void);
  146.         virtual BOOL     FQueryPrinterSetup(void);
  147.         virtual BOOL     FQueryObjectSelected(HMENU);
  148.  
  149.         virtual UINT     ULoad(BOOL, LPSTR);
  150.         virtual UINT     USave(UINT, LPSTR);
  151.  
  152.         virtual BOOL     Print(HWND);
  153.         virtual UINT     PrinterSetup(HWND, BOOL);
  154.  
  155.         virtual BOOL     FClip(HWND, BOOL);
  156.         virtual BOOL     FQueryPaste(void);
  157.         virtual BOOL     FPaste(HWND);
  158.         virtual BOOL     FPasteSpecial(HWND);
  159.  
  160.         //CHAPTER12MOD
  161.         virtual BOOL     FQueryEnableEditLinks(void);
  162.         virtual BOOL     FEditLinks(HWND);
  163.         virtual BOOL     FShowOrQueryObjectTypes(BOOL, BOOL);
  164.         //End CHAPTER12MOD
  165.  
  166.         virtual UINT     NewPage(void);
  167.         virtual UINT     DeletePage(void);
  168.         virtual UINT     NextPage(void);
  169.         virtual UINT     PreviousPage(void);
  170.         virtual UINT     FirstPage(void);
  171.         virtual UINT     LastPage(void);
  172.         virtual void     Rename(LPSTR);
  173.         virtual BOOL     FInsertObject(HWND);
  174.         virtual void     ActivateObject(UINT);
  175.     };
  176.  
  177. typedef CPatronDoc FAR * LPCPatronDoc;
  178.  
  179.  
  180. //Drag-drop interfaces we need in the document
  181.  
  182. class __far CDropTarget : public IDropTarget
  183.     {
  184.     protected:
  185.         ULONG               m_cRef;      //Interface reference count.
  186.         LPCPatronDoc        m_pDoc;      //Back pointer to the document
  187.  
  188.         LPDATAOBJECT        m_pIDataObject;  //Data object from DragEnter
  189.         BOOL                m_fPendingRepaint;
  190.         POINTL              m_ptPick;        //Pick-up offsets
  191.         POINTL              m_ptLast;        //Last drag point
  192.         SIZEL               m_szl;           //Object size
  193.         BOOL                m_fFeedback;     //Draw feedback?
  194.         FORMATETC           m_fe;            //Real dropping format.
  195.  
  196.     public:
  197.         CDropTarget(LPCPatronDoc);
  198.         ~CDropTarget(void);
  199.  
  200.         //IDropTarget interface members
  201.         STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  202.         STDMETHODIMP_(ULONG) AddRef(void);
  203.         STDMETHODIMP_(ULONG) Release(void);
  204.  
  205.         STDMETHODIMP DragEnter(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
  206.         STDMETHODIMP DragOver(DWORD, POINTL, LPDWORD);
  207.         STDMETHODIMP DragLeave(void);
  208.         STDMETHODIMP Drop(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
  209.     };
  210.  
  211.  
  212. typedef CDropTarget FAR * LPCDropTarget;
  213.  
  214.  
  215. class __far CDropSource : public IDropSource
  216.     {
  217.     protected:
  218.         ULONG               m_cRef;      //Interface reference count.
  219.  
  220.     public:
  221.         CDropSource(void);
  222.         ~CDropSource(void);
  223.  
  224.         //IDropSource interface members
  225.         STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  226.         STDMETHODIMP_(ULONG) AddRef(void);
  227.         STDMETHODIMP_(ULONG) Release(void);
  228.  
  229.         STDMETHODIMP QueryContinueDrag(BOOL, DWORD);
  230.         STDMETHODIMP GiveFeedback(DWORD);
  231.     };
  232.  
  233.  
  234. typedef CDropSource FAR * LPCDropSource;
  235.  
  236.  
  237.  
  238. #endif //_PATRON_H_
  239.